import dateOpt from '@/biz/option/date.js';
import Opt from '@/components/dt/info/Opt.js';
import table from '@/components/dt/table/render.js';


let _this = null;
let approvalStatusList = [
  { value: '已通过', key: '1' },
  { value: '已驳回', key: '2' },
  { value: '待审核', key: '3' },
]
class leaveCaseColumns extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
    {
      title: '文章标题',
      field: 'articleTitle',
      minWidth: 140,
    },
    {
      title: '所属楼盘',
      field: 'buildingAlias',
      minWidth: 160,
    },
    {
      title: '审核状态',
      field: 'auditStatus',
      minWidth: 120,
      slots: {
        default: (params, h) => {
          return table.cell.text(h, {
            value: params.row.auditStatus == 1 ? '已通过' : params.row.auditStatus ==
              2 ? '已驳回' : params.row.auditStatus == 3 ?
              '待审核' : '-'
          })
        }
      },
      header: {
        filter: {
          title: '审核状态',
          key: 'auditStatus', // 1，已通过 2，已驳回 3，待审核
          select: {
            options: approvalStatusList
          }
        }
      }
    },
    {
      title: '上架状态',
      field: 'hasConfig',
      minWidth: 120,
      slots: {
        default: (params, h) => {
          return table.cell.text(h, {
            value: params.row.hasConfig == 1 ? '已上架' : '已下架'
          })
        }
      },
      header: {
        filter: {
          title: '上架状态',
          key: 'hasConfig', // 
          select: {
            options: [{
              key: '1',
              value: '已上架'
            }, {
              key: '0',
              value: '已下架'
            }]
          }
        }
      }
    },
    {
      title: '创建时间',
      field: 'createTime',
      minWidth: 180,
      header: {
        filter: dateOpt.range({
          title: '创建时间',
          startKey: 'beginTime',
          endKey: 'endTime',
        }),
      }
    },
    {
      title: '创建人',
      field: 'creater',
      minWidth: 100,
    },
    {
      title: '敏感字校验',
      field: 'sensitiveValid',
      minWidth: 120,
      slots: {
        default: (params, h) => {
          return table.cell.text(h, {
            value: params.row.sensitiveValid == 1 ? '通过' : '不通过'
          })
        }
      }
    },
    {
      title: '当前审批节点',
      field: 'nextReviewer',
      minWidth: 180,
    },
    {
      title: '操作',
      field: 'operation',
      width: 200,
      align: 'center',
      fixed: 'right',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'articleViewFun',
            data: params.row
          })
          if (params.row.auditStatus != '3') {
            btns.push({
              title: _this.unlocking('0107030200') ? '编辑' : '',
              event: 'articleEditFun',
              data: params.row
            })
          }
          btns.push({
            title: _this.unlocking('0107030300') ? '删除' : '',
            event: 'deleteFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
  }

}


export default leaveCaseColumns